package com.daodway.designpattern.statepattern;

import java.awt.Point;

public class Miner extends BaseGameEntity {
	private StateMachine<Miner> m_pStateMachine;
	//旷工的位置
	public Point m_location;
	//矿工挖的金子数量
	public int m_iGoldCarried;
	//矿工在银行存的钱
	public int m_iMoneyInBank;
	//价值越高,矿工越渴
	public int m_iThirst;
	//价值越高,矿工越累
	public int m_iFatingue;
	public Miner(long ID,String name) {
		super(ID,name);
		m_pStateMachine=new StateMachine(this);
		m_pStateMachine.setM_pCurrentState(EnterMineAndDigForNugget.Instance());
	}
	public void ChangeState(State<Miner> pNewState){
		m_pStateMachine.ChangeState(pNewState);
	}
	@Override
	public void update() {
		// TODO Auto-generated method stub
		m_iThirst+=5;
		if(m_pStateMachine!=null){
			m_pStateMachine.Update();
		}
	}
	//获取矿工位置
	public Point Location(){
		return m_location;
	}
	//获取矿工位置
	public void ChangeLocation(Point p){
		m_location=p;
	}	
	// 挖掘金子
	public void  AddToGoldCarried(int glodCarried){
		m_iGoldCarried+=glodCarried;
	}
	//增加疲惫度;
	public void IncreaseFatgue(){
		m_iFatingue+=5;
	}
	//是否开采了足够多的金子
	public boolean PocketFull(){
		boolean flag=false;
		if(m_iGoldCarried>=3){
			flag=true;
		}
		return flag;
	}
	//是否口渴了
	public boolean isThirsty(){
		boolean flag=false;
		if(m_iThirst>=10){
			flag=true;
		}
		return flag;		
	}
	public boolean ifHaveMoney(){
		boolean flag=false;
		if(m_iMoneyInBank>0){
			flag=true;
		}
		return flag;
	}
	@Override
	public boolean HandleMessage(Telegram msg) {
		return	m_pStateMachine.HandleMessage(msg);
	}
	
}
